package com.gomokult.servlet.gamelib;

import com.gomokult.exception.InvalidIDException;
import com.gomokult.service.impl.GamesLibraryServiceImpl;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
/**
 * 文件：DeleteCommentServlet.java
 * 作者：赵哲群
 * 完成度：已完成
 * 最后修改日期：2023-7-6
 */
@WebServlet("/servlet/GetLikeStateServlet")
public class GetLikeStateServlet extends HttpServlet {
    public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        PrintWriter out = response.getWriter();
        int userid = Integer.parseInt(request.getParameter("userID"));
        int gameid = Integer.parseInt(request.getParameter("gameID"));
        try {
            boolean flag = GamesLibraryServiceImpl.getSingleton().getLikeState(userid,gameid);
            if(flag)
                out.print(1);
            else
                out.print(0);
        } catch (InvalidIDException e) {
            out.print("#InvalidIDException");
        }
    }
}
